package com.fang.config.beanInitialize;

import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Component;

import java.util.Objects;

/**
 * @author Fang Ruichuan
 * @date 2022-12-27 9:12
 */
@Component
public class DoByApplicationListener implements ApplicationListener<ContextRefreshedEvent> {

    public DoByApplicationListener() {
        System.out.println("DoByApplicationListener constructor");
    }

    @Override
    public void onApplicationEvent(ContextRefreshedEvent event) {
        if (Objects.isNull(event.getApplicationContext().getParent())) {
            System.out.println("DoByApplicationListener do something");
        }
    }
}
